import type { MultipleConditionSearchSchema } from '@/components/multiple-condition-search'
import { LicenseSourceOptions } from '@/constants/cdn-node'

export default function useConfig() {
  const tableColumns = computed(() =>
    buildColumns([
      {
        title: '证书域名',
        dataIndex: 'domain',
        slotName: 'domain',
        // format: 'copy'
      },
      {
        title: '所属应用',
        dataIndex: 'app_id',
        slotName: 'appId',
      },
      {
        title: '证书品牌',
        dataIndex: 'brand',
        slotName: 'brand',
      },
      {
        title: '证书来源',
        dataIndex: 'source',
        slotName: 'source',
      },
      {
        title: '触发方式',
        dataIndex: 'trigger_source',
        slotName: 'trigger_source',
      },
      {
        title: '申请状态',
        dataIndex: 'status',
        slotName: 'status',
      },
      {
        title: '申请时间',
        dataIndex: 'created_at',
        sortable: sortableSettings,
        format: 'date-time',
      },
      // {
      //   title: '过期时间',
      //   dataIndex: 'expired_at',
      //   sortable: sortableSettings,
      //   format: 'date-time',
      // },
      {
        title: '操作',
        fixed: 'right',
        slotName: 'actions',
        width: 80,
        cellClass: 'actions-cell',
      },
    ]),
  )

  const searchSchema = ref<MultipleConditionSearchSchema>({
    placeholder: '默认按照证书域名搜索',
    widgets: [
      {
        label: '证书域名',
        field: 'domain_keyword',
        maxLength: 30,
        type: 'input',
      },
      {
        label: '证书品牌',
        field: 'brand_keyword',
        type: 'input',
      },
      {
        label: '证书来源',
        field: 'source',
        type: 'select',
        placeholder: '请选择值证书来源',
        options: LicenseSourceOptions,
      },
      {
        label: '申请状态',
        field: 'status',
        type: 'select',
        placeholder: '请选择值证书来源',
        options: [
          { label: '已成功', value: 1 },
          { label: '已失败', value: 2 },
          { label: '申请中', value: 3 },
        ],
      },
      // {
      //   label: '更新时间',
      //   field: 'name_keyword',
      //   maxLength: 30,
      //   type: 'input',
      // },
      // {
      //   label: '过期时间',
      //   field: 'site_domain_keyword',
      //   type: 'input',
      // },
    ],
  })

  return {
    tableColumns,
    searchSchema,
  }
}
